img = imread('2.jpg');
gray = img(:,:,1);

imshow(gray)
hold on;
% gradient
[fx,fy] = gradient(double(g1));

% x location of brightest point
maxX = max(fx);
MAX = 0;

for i = 1:size(fx)
if MAX < maxX(i)
MAX = maxX(i);
bright_X = i;
end
end

figure(1);
imshow(gray);
hold on;
plot(bright_X, 1:length(fx), 'r*')

% y location of brightest point
maxY = max(fy);
MAX = 0;

for i = 1:size(fy)
if MAX < maxY(i)
MAX = maxY(i);
bright_Y = i;
end
end

%plot(1:length(fy), bright_Y, 'b*')

plot(1:length(max(fx)),max(fx));
plot(max(fy), 1:length(max(fy)));

plot(bright_X, bright_Y, 'g*')